# coding: UTF-8
# Filename : common.py
# Company : imedia
# Author : hui
# -*-coding:utf-8 -*-

from django.http import HttpResponse
import httputils, xml_tpl, err_tpl, const

#请求验证
def validate(request):
    md5_param = httputils.post(request, 'md5_param')
    secret = httputils.post(request, 'secret')
    if const.validate and not httputils.do_check(request, md5_param, secret):
        return response(err_tpl.validate_error)
    
#HTTP响应
def response(data):
    response = HttpResponse(mimetype='application/xml charset=UTF-8') 
    response.write(xml_tpl.xml_head + data)
    return response
